home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / asm3.zip / POPDIR.ASM < prev    next >
Assembly Source File  |  1986-03-03  |  2KB  |  96 lines

  1. main    group    code
  2. code    segment    public    para    'code'
  3. assume    cs:main
  4.  
  5. org    100h                ;.COM file
  6.  
  7. BEGIN:    jmp    START            ;program starts here
  8.         db    "Copyright 1986 Ziff-Davis Publishing Co.",1Ah
  9. signature    db    'PUSHDIR VERSION 1.0'
  10. lengthsignature = $ - signature
  11.  
  12. savedint16    dd    ?        ;used to be identical to pushdir
  13.  
  14. nextpush    dw    offset main:push1dir    ;next place to save a dir
  15. push1dir    db    67 dup (0)
  16. push2dir    db    67 dup (0)
  17. push3dir    db    67 dup (0)
  18. push4dir    db    67 dup (0)
  19. push5dir    db    67 dup (0)
  20. push6dir    db    67 dup (0)
  21.  
  22. ;up to here must be EXACTLY identical in both PUSHDIR and POPDIR.
  23.  
  24. notinstalled1    db    'Must run PUSHDIR.COM before POPDIR.COM'
  25.         db    ' will do anything.',13,10,10,'$'
  26. errpop1        db    'Error popping the current directory',13,10,10,'$'
  27.  
  28. START:
  29.     sti                ;interrupts on
  30.  
  31.     ;is PUSHDIR already installed ?
  32.  
  33.     mov    ax,7788h            ;signature request
  34.     mov    bx,7789h            ;signature request
  35.     mov    si,offset main:signature    ;point ds:si to signature
  36.     int    16h            ;is it installed ?
  37.     
  38. assume    ds:nothing
  39.     
  40.     cmp    bx,7788h            ;were ax and bx switched ?
  41.     jne    NOTINSTALLED        ;no
  42.     cmp    ax,7789h            ;were ax and bx switched ?
  43.     jne    NOTINSTALLED        ;no
  44.     jmp    short ISINSTALLED        ;yes - continue, no error
  45. NOTINSTALLED:
  46.  
  47.     ;here PUSHDIR was not previously installed so POPDIR can't do anything
  48.     ;useful so we just terminate with an error message.
  49.  
  50.     mov    dx,offset main:notinstalled1    ;error message
  51.     mov    ah,9
  52.     int    21h
  53.     int    20h            ;exit
  54.  
  55.  
  56. ISINSTALLED:
  57.  
  58.     ;get the address of the directory previously saved by pushdir
  59.  
  60.     mov    bp,ds:[nextpush]        ;get the next push location
  61.     sub    bp,67                ;back up one to the last push
  62.     cmp    ds:[nextpush],offset main:push1dir    ;need to wrap back ?
  63.     jne    NOWRAPBACK            ;no
  64.     mov    bp,offset main:push6dir        ;yes, wrap back
  65. NOWRAPBACK:
  66.  
  67.     ;set the current directory
  68.  
  69.     mov    dx,bp            ;load ds:dx with directory to set
  70.     mov    ah,3bh            ;dos function number
  71.     int    21h            ;set current dir back
  72.     jc    ERRPOP            ;branch on error
  73.     mov    ds:[nextpush],bp    ;update [nextpush] if successful
  74.  
  75.     ;set the current drive also    
  76.  
  77.     mov    dl,ds:[bp]            ;get drive letter from path
  78.     sub    dl,'A'                ;convert to binary (0=A, 1=B)
  79.     mov    ah,0eh                ;dos function number
  80.     int    21h                ;set drive
  81.  
  82.     ;exit successfully with no message
  83.  
  84.     int    20h                 ;exit
  85.  
  86. ERRPOP:
  87.     push    cs
  88.     pop    ds                ;set ds = cs
  89.     mov    dx,offset main:errpop1        ;error message
  90.     mov    ah,9                ;dos function number
  91.     int    21h                ;show the message
  92.     int    20h                ;terminate
  93.     
  94. code    ends
  95. end    BEGIN                ;start execution at BEGIN
  96.